package com.ls.es;

import java.net.InetAddress;
import java.net.UnknownHostException;

import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Config {

	@Bean
	public TransportClient getClient() throws UnknownHostException{
		InetSocketTransportAddress addr = new InetSocketTransportAddress(InetAddress.getByName("172.20.4.208"),9300);
		Settings setting = Settings.builder().put("cluster.name","esCluster").build();
		TransportClient client = new PreBuiltTransportClient(setting);
		client.addTransportAddress(addr);
		return client;
	}
}
